package com.yucquan.app;


import android.app.Activity;

import com.exteam.common.util.CommLogger;
import com.exteam.model.ModelApp;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by wushoud on 15-5-26.
 */
public class UserApp extends ModelApp {
    @Override
    public void onCreate() {
        super.onCreate();
        CommLogger.d("UserApp App init   ");
        super.initData();
    }

    private List<Activity> mList = new LinkedList<>();
    private static UserApp instance;

    public synchronized static UserApp getInstance() {
        if (null == instance) {
            instance = new UserApp();
        }
        return instance;
    }

    // add Activity
    public void addActivity(Activity activity) {
        mList.add(activity);
    }

    public void exit() {
        try {
            for (Activity activity : mList) {
                if (activity != null)
                    activity.finish();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            System.exit(0);
        }
    }

    public void onLowMemory() {
        super.onLowMemory();
        System.gc();
    }
}
